import java.io.IOException;
import java.util.Random;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;


public class Diamond {
	
	public int x,y , type;
	public static int width, height;
	public static Image img[];
	public static boolean isDraw = false;
	
	public static Random random = new Random(System.currentTimeMillis());
	public int ran;
	
	
	static {
		try {
			if(img == null)
			{
				img = new Image[6];
				for(int i=0; i< img.length; i++)
				{
					img[i] = Image.createImage("/diamond"+i+".png");
				}
				width = img[0].getWidth();
				height = img[0].getHeight();
			}					
	
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public Diamond(int x1, int y1) {
	
		x = x1;
		y = y1;
		
		type = abs(random.nextInt(6));
		System.out.println(type);
		
		
	}
	
	
	
	public int abs(int t)
	{
		if(t<0)
		{
			t *= -1;
		}
		return  t;
	}
	
	
	public boolean collison(int x2, int y2, int w2, int h2)
	{
		if( ((x2 + w2/2 >= x && x2 + w2/2 <= x + width) || (x2 <= x + width && x2 >= x) || (x2 + w2 >= x && x2
				+ w2 <= x + width)) && ((y2>=y && y2 <= y+height) ||( y2+ h2>=y && y2+h2<=y+height) ))
		{			
			return true;
		}
		return false;
	}
	
	public void paint(Graphics g)
	{
		//if(isDraw)
		{
			g.drawImage(img[type], x, y,  Graphics.HCENTER|Graphics.VCENTER);
		}
	}

}
